package com.ktjiaoyu.springboothelloworld.controller;

import com.ktjiaoyu.springboothelloworld.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@PropertySource("classpath:database.properties")
public class HelloController {
    @Value("${name}")
    private String name;
    @Value("${age}")
    private int age;

    @Value("${driver}")
    private String driver;

//    @Resource
//    private User user;

    @RequestMapping("/test")
    public String test() {
        return "hello world";
    }

    @RequestMapping("/test2")
    public String test2() {
        return "hello world name=" + name + ",age=" + age;
    }

//    @RequestMapping("/test3")
//    public String test3(){
//        return "hello world name="+user.getUsername()+",age="+user.getAge();
//    }

    @RequestMapping("/test4")
    public String test4() {
        return "hello world driver=" + driver;
    }
}
